package com.kfh.ybracelet.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 登录返回的bean
 * Created by Aaron on 15/8/12.
 */
public class LoginResult implements Parcelable {

    /**
     * data : {"id":3,"mobile":"15311280989","nickName":"lee","userImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-03-03/75m8jqhz70blhg8teyt621zk82673kish5trd6y8wbml0dz2puqtlm69jfz4o9i1_s","sex":"男","birthDay":"1995-04-02","mqttIp":"121.40.98.39","mqttPort":9921,"topicList":[{"topic":"15311280989;18310861283","topicName":"小丽","topicImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com/2015-11-27/le9cmojl0nrjxsz5xiqo6i68ke9ra0h2_s"},{"topic":"15311280989;18610915892","topicName":"冯","topicImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-01-25/v65fu9khaab7pbv51g1djcyah3fwdzbv4wjlvsac2mm81ci1ue5zmkr8phah1l31_s"},{"topic":"15311280989;17600859617","topicName":"哦ll","topicImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-03-10/kootc0p2lhcxtq0oh6t4u145ql8p7olpxbt107bq6xwal3qdf8z3bkw0jtxrw3d4_s"},{"topic":"15225087687;15311280989","topicName":"join","topicImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com/2016-01-12/3iaoxcs21x2vc0d2tr808kfpvqusu5r7_s"},{"topic":"56e66fccf2696d3025c5d3b0","topicName":"创客","topicImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-03-14/dm5grjw5dq8vtudzo36y75gqcip8q118zdayy9inwclgpvham3am36fkqt0g8qyf"}]}
     * token : {"token":"15311280989llja902vs2joa5mazxv427i2ptzyln3a1458026274339","expireTime":1460618274339}
     * code : 0
     * code_msg : 成功
     */

    public DataEntity data;
    public TokenEntity token;
    public int code;
    public String code_msg;

    public static class DataEntity implements Parcelable {
        /**
         * id : 3
         * mobile : 15311280989
         * nickName : lee
         * userImg : http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-03-03/75m8jqhz70blhg8teyt621zk82673kish5trd6y8wbml0dz2puqtlm69jfz4o9i1_s
         * sex : 男
         * birthDay : 1995-04-02
         * mqttIp : 121.40.98.39
         * mqttPort : 9921
         * topicList : [{"topic":"15311280989;18310861283","topicName":"小丽","topicImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com/2015-11-27/le9cmojl0nrjxsz5xiqo6i68ke9ra0h2_s"},{"topic":"15311280989;18610915892","topicName":"冯","topicImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-01-25/v65fu9khaab7pbv51g1djcyah3fwdzbv4wjlvsac2mm81ci1ue5zmkr8phah1l31_s"},{"topic":"15311280989;17600859617","topicName":"哦ll","topicImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-03-10/kootc0p2lhcxtq0oh6t4u145ql8p7olpxbt107bq6xwal3qdf8z3bkw0jtxrw3d4_s"},{"topic":"15225087687;15311280989","topicName":"join","topicImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com/2016-01-12/3iaoxcs21x2vc0d2tr808kfpvqusu5r7_s"},{"topic":"56e66fccf2696d3025c5d3b0","topicName":"创客","topicImg":"http://7xn7x2.com2.z0.glb.qiniucdn.com//group/2016-03-14/dm5grjw5dq8vtudzo36y75gqcip8q118zdayy9inwclgpvham3am36fkqt0g8qyf"}]
         */

        public int id;
        public String mobile;
        public String nickName;
        public String userImg;
        public String sex;
        public String birthDay;


//        public String mqttIp;
//        public String mqttPort;
//        public List<TopicBean> topicList;
//
//        public static class TopicListEntity {
//            /**
//             * topic : 15311280989;18310861283
//             * topicName : 小丽
//             * topicImg : http://7xn7x2.com2.z0.glb.qiniucdn.com/2015-11-27/le9cmojl0nrjxsz5xiqo6i68ke9ra0h2_s
//             */
//
//            public String topic;
//            public String topicName;
//            public String topicImg;
//
//        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(this.id);
            dest.writeString(this.mobile);
            dest.writeString(this.nickName);
            dest.writeString(this.userImg);
            dest.writeString(this.sex);
            dest.writeString(this.birthDay);
//            dest.writeString(this.mqttIp);
//            dest.writeString(this.mqttPort);
//            dest.writeTypedList(topicList);
        }

        public DataEntity() {
        }

        protected DataEntity(Parcel in) {
            this.id = in.readInt();
            this.mobile = in.readString();
            this.nickName = in.readString();
            this.userImg = in.readString();
            this.sex = in.readString();
            this.birthDay = in.readString();
//            this.mqttIp = in.readString();
//            this.mqttPort = in.readString();
//            this.topicList = in.createTypedArrayList(TopicBean.CREATOR);
        }

        public static final Parcelable.Creator<DataEntity> CREATOR = new Parcelable.Creator<DataEntity>() {
            public DataEntity createFromParcel(Parcel source) {
                return new DataEntity(source);
            }

            public DataEntity[] newArray(int size) {
                return new DataEntity[size];
            }
        };
    }

    public static class TokenEntity implements Parcelable {
        /**
         * token : 15311280989llja902vs2joa5mazxv427i2ptzyln3a1458026274339
         * expireTime : 1460618274339
         */

        public String token;
        public long expireTime;

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(this.token);
            dest.writeLong(this.expireTime);
        }

        public TokenEntity() {
        }

        protected TokenEntity(Parcel in) {
            this.token = in.readString();
            this.expireTime = in.readLong();
        }

        public static final Parcelable.Creator<TokenEntity> CREATOR = new Parcelable.Creator<TokenEntity>() {
            public TokenEntity createFromParcel(Parcel source) {
                return new TokenEntity(source);
            }

            public TokenEntity[] newArray(int size) {
                return new TokenEntity[size];
            }
        };
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(this.data, 0);
        dest.writeParcelable(this.token, 0);
        dest.writeInt(this.code);
        dest.writeString(this.code_msg);
    }

    public LoginResult() {
    }

    protected LoginResult(Parcel in) {
        this.data = in.readParcelable(DataEntity.class.getClassLoader());
        this.token = in.readParcelable(TokenEntity.class.getClassLoader());
        this.code = in.readInt();
        this.code_msg = in.readString();
    }

    public static final Parcelable.Creator<LoginResult> CREATOR = new Parcelable.Creator<LoginResult>() {
        public LoginResult createFromParcel(Parcel source) {
            return new LoginResult(source);
        }

        public LoginResult[] newArray(int size) {
            return new LoginResult[size];
        }
    };
}
